You can specify a completion routine as the seventh parameter to the SndStartFilePlay function. The completion routine executes when the sound file finishes playing (unless sound play was stopped by the SndStopFilePlay function).
A Sound Manager completion routine has the following syntax:
PROCEDURE MyFilePlayCompletionRoutine (chan: SndChannelPtr);
The Sound Manager executes your completion routine when a play from disk on the channel specified by the chan parameter finishes. You might use the completion routine to set a global flag that alerts the application that it must dispose of the sound channel.
A completion routine is called at interrupt time. It must not make any calls to the Memory Manager, either directly or indirectly. If your completion routine needs to access your application's global variables, you must ensure that register A5 contains your application's A5. (You can use the userInfo field of the sound channel pointed to by the chan parameter to pass that value to your completion routine.)
Because this routine is called at interrupt time, it must preserve all registers other than A0-A1 and D0-D2.
For information on how you can use completion routines to help manage an asynchronous play from disk, see "Managing an Asynchronous Play From Disk" .
| Previous | Chapter contents | Chapter top | Section top | Next |